package com.zh.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zh.auth.domain.dto.PagePermissionDto;
import com.zh.web.domain.auth.entity.Permission;
import org.apache.ibatis.annotations.MapKey;
import org.mapstruct.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {
    List<Permission> listPermission(IPage<Permission> page, PagePermissionDto pagePermissionDto);
    Integer selectCountByCode(Integer permissionCode);

    /**
     * 根据用户ID查询权限编码集合
     * @param id 用户ID
     * @return 权限编码集合
     */
    List<Integer> findPermissionCodesByUserId(Long id);

    /**
     * 查询权限编码与权限名称的映射
     * @return
     */

    @MapKey("permission_name")
    List<Map<String, Object>> findPermissionName2Code();

    Integer permanentlyDeleteByIds(List<Integer> codes);

    void permanentlyDelete();
}
